#include "dri.h"
#include "ksyscall.h"
#include "process.h"


void dri_syscall_initialize(syscall_handler handler){
	//DO NOTHING
	//LINKED IN DRIVERS ARE IN KMODE ALREADY SO
	//NO SYSCALLS ARE USED
}


void dri_driver_main_stub(){
	//DO NOTHING
	//LINKED IN DRIVERS ARE IN KMODE ALREADY SO
	//NO KMODE MAIN FUNCTION IS NEEDED
}

void dri_register_driver(dri_driver_descriptor_t *desc){
	if (desc->driver_magic != DRI_DRIVER_MAGIC)
		return;//TODO : Signal error
	switch (desc->driver_class){
		case DRI_CLASS_CHAR://Simple stream drivers like TTY
			break;//TODO: Implement interface
		case DRI_CLASS_BLOCK://Seekable block based drivers, like storage
			break;
		case DRI_CLASS_IFS://Installable (meta)filesystem drivers
			ifs_register((ifs_descriptor_t *)desc->driver_class_desc);
			break;
		default:
			//TODO:Signal error
			break;
	}
	enter_module_code();
	desc->init_sci(ksyscall_dispatch);
	desc->driver_main();
	exit_module_code();
}